<template>
  <el-header>
    <el-icon
      v-if="!homeStore.isCollapse"
      style="font-size: 24px; cursor: pointer"
      @click="close"
    >
      <Fold />
    </el-icon>
    <el-icon v-else style="font-size: 24px; cursor: pointer" @click="open">
      <Expand />
    </el-icon>
    <el-space>
      <span>欢迎你，{{ homeStore.adminname }}</span>
      <el-button @click="exit">退出</el-button>
    </el-space>
  </el-header>
</template>

<script lang="ts" setup>
import { useHomeStore } from "@/stores/home";
import { useRouter } from "vue-router";
const router = useRouter();

const homeStore = useHomeStore();
const close = () => {
  homeStore.isCollapse = true;
};
const open = () => {
  homeStore.isCollapse = false;
};
const exit = () => {
  localStorage.clear();
  homeStore.adminname = "";
  homeStore.token = "";
  homeStore.checkedkeys = "[]";
  router.push("/login");
};
</script>
